package com.school.gift.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.school.gift.domain.Order;
import com.school.gift.mapper.OrderMapper;
import com.school.gift.model.OrderModel;
import com.school.gift.service.OrderService;
import zhibi.common.support.base.Page;
import zhibi.common.support.base.service.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import zhibi.common.support.mybatis.example.Example;

/**
* The class create by 执笔 on generate.
*/
@Service
@Transactional
public class OrderServiceImpl extends BaseServiceImpl<Order> implements OrderService {

    @Autowired
    public OrderServiceImpl(OrderMapper mapper) {
        super(mapper);
        this.orderMapper = mapper;
    }
    private OrderMapper orderMapper;

    @Override
    public PageInfo<OrderModel> selectModel(Example example, Page page) {
        if(null != page){
            PageHelper.startPage(page.getPageNum(),page.getPageSize());
        }
        return new PageInfo<>(orderMapper.selectModel(example),Page.NAV_SIZE);
    }

    @Override
    public OrderModel selectModelById(Long id) {
        return orderMapper.selectModelById(id);
    }

    @Override
    public Double selectSumByDate(String date) {
        date = "%"+date+"%";
        return orderMapper.selectSumByDate(date);
    }
}